home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / mach / amiga / scsi9091.lzh / createport.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-24  |  797 b   |  42 lines

  1. #include <exec/types.h>
  2. #include <exec/ports.h>
  3. #include <exec/memory.h>
  4. #ifdef __GNUC__
  5. #define BASE_EXT_DECL
  6. #define BASE_NAME (*(void **)4)
  7. #include <inline/exec.h>
  8. #endif
  9.  
  10. struct MsgPort *
  11. CreatePort(name, pri)
  12.     char *name;
  13.     LONG pri;
  14. {
  15.   int sigBit;
  16.   struct MsgPort *port;
  17.   
  18.   if ((sigBit = AllocSignal(-1)) == -1) return NULL;
  19.   
  20.   port = (struct MsgPort *)AllocMem(sizeof(struct MsgPort), MEMF_CLEAR|MEMF_PUBLIC);
  21.   if (! port)
  22.     {
  23.       FreeSignal(sigBit);
  24.       return NULL;
  25.     }
  26.     
  27.   port->mp_Node.ln_Name = name;
  28.   port->mp_Node.ln_Pri = pri;
  29.   port->mp_Node.ln_Type = NT_MSGPORT;
  30.   
  31.   port->mp_Flags = PA_SIGNAL;
  32.   port->mp_SigBit = sigBit;
  33.   port->mp_SigTask = FindTask(0);
  34.   
  35.   if (name)
  36.     AddPort(port);
  37.   else
  38.     NewList(&(port->mp_MsgList));
  39.     
  40.   return port;
  41. }
  42.